#ifndef MEDIAPLAYER_H
#define MEDIAPLAYER_H

#include <QWidget>
#include <QMediaPlayer>
#include <QListwidgetItem>
QT_BEGIN_NAMESPACE
namespace Ui { class MediaPlayer; }
QT_END_NAMESPACE

class QMediaPlaylist;
class MediaPlayer : public QWidget
{
    Q_OBJECT

public:
    MediaPlayer(QWidget *parent = nullptr);
    ~MediaPlayer();

private slots:
    ///自定义槽函数
    void onStateChanged (QMediaPlayer::State state);
    void onPlaylistChanged (int position) ;
    void onDurationChanged (qint64 duration) ;
    void onPositionChanged(qint64 position) ;
    void on_pushButton_AddSong_clicked();

    ///ui控件自动关联槽函数
    void on_pushButton_removeSong_clicked();

    void on_pushButton_CleanSong_clicked();

    void on_listWidget_doubleClicked(const QModelIndex &index);

    void on_pushButton_play_clicked();

    void on_slider_Volume_valueChanged(int value);

    void on_sliderPosition_valueChanged(int value);

    void on_pushButton_volumn_clicked();

private:
    Ui::MediaPlayer *ui;

    QMediaPlayer *mPlayer = nullptr;  //播放器
    QMediaPlaylist *mPlayList = nullptr; //播放器列表

    QString mDurationTime="00:00"; //总长度
    QString mPositionTime = "00:00";//当前播放到的位置
};
#endif // MEDIAPLAYER_H
